import type { AxiosResponseType } from '@/types/http'
import { requestAPI } from '@/utils/http/request'

/**
 *  获取日志列表
 * @param data
 * @returns
 */
export const getTaskLogList = (pageNo: number, pageSize: number) => {
  let url = `/admin-api/business/monitor/task/logs?pageNo=${pageNo}&pageSize=${pageSize}`
  return requestAPI.get<
    AxiosResponseType<{
      list: {
        id: number
        ip: string
        taskName: string
        taskStatus: string
        taskMsg: string
        duration: number
        createTime: number
      }[]
      total: number
    }>
  >(url)
}

/**
 *  获取服务器状态列表
 * @param data
 * @returns
 */
export const getServerStatusList = () => {
  let url = `/admin-api/business/monitor/system/status`
  return requestAPI.get<
    AxiosResponseType<
      {
        ip: string
        cpuUsagePercent: string
        menUsagePercent: string
        diskUsagePercent: string
        status: string
      }[]
    >
  >(url)
}
/**
 * 获取监控统计
 */
export const getMonitorSummary = () => {
  let url = `/admin-api/business/monitor/summary`
  return requestAPI.get<AxiosResponseType<{ todayCount: number; errorPercent: string; respTimeAvg: number }>>(url)
}
/**
 * 数据来源分布
 * @returns
 */
export const getDataSource = () => {
  let url = `/admin-api/business/monitor/data/source`
  return requestAPI.get<AxiosResponseType<{ name: string; value: number }[]>>(url)
}
